package com.welink.cmp.adapter.api.metadata.query;

import com.welink.cmp.dto.metadata.MetadataIdListQry;
import com.welink.cmp.dto.metadata.MetadataIdQry;
import com.welink.cmp.dto.metadata.switchs.clientobject.SwitchBasicCO;
import com.welink.cmp.dto.metadata.switchs.query.*;
import com.welink.cmp.meatdata.service.SwitchAppService;
import com.welink.common.dto.MultiResponse;
import com.welink.common.dto.PageResponse;
import com.welink.common.dto.SingleResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 交换机查询服务API
 *
 * @create
 */
@RestController("/api/switch/query")
public class SwitchQueryServiceApi {

    @Autowired
    private SwitchAppService switchAppService;

    /**
     * [ID查询]查询交换机信息详情
     * @param idQry 主键ID
     * @return Switch DTO
     */
    @GetMapping("/sw-item/{id}")
    public SingleResponse<SwitchBasicCO> querySwitchById(@PathVariable MetadataIdQry idQry){
        SwitchBasicCO dto = switchAppService.getSwitchById(idQry.getId());
        return SingleResponse.of(dto);
    }

    /**
     * [列表查询]列表查询交换机信息
     * @param listQuery 列表查询指令
     * @return Switch DTO列表
     */
    @GetMapping("/sw-list")
    public MultiResponse<SwitchBasicCO> listQuerySwitch(@RequestBody MetadataIdListQry listQuery){
        List<SwitchBasicCO> list = switchAppService.switchListQuery(listQuery);
        return MultiResponse.of(list);
    }

    /**
     * [分页查询]分页查询交换机信息
     * @param pageQry 分页查询指令
     * @return Switch DTO分页结果
     */
    @GetMapping("/sw-page")
    public PageResponse<SwitchBasicCO> pageQuerySwitch(@RequestBody SwitchListByPageQry pageQry){
        return switchAppService.switchPageQuery(pageQry);
    }
}